package com.chb.system.controller.apis;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chb.system.annotation.OperLogAnnotation;
import com.chb.system.service.NoticeService;
import com.chb.system.vo.NoticeVo;
import com.hos.entity.sys.Notice;
import com.hos.entity.sys.Role;
import com.hos.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：张家琪
 * @date ：Created in 2023/12/16 10:42
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("system/api/notice")
@Api(value = "通知公告相关接口", tags = "通知公告相关接口")
public class APINoticeServiceController {
    @Autowired
    private NoticeService noticeService;

    @GetMapping("selectAllNotice")
    @ApiOperation(value = "查询所有可用的通知公告接口")
    public Result selecAlltNotice() {
        return new Result<>(200, "查询成功", noticeService.selecAlltNotice());
    }

    @PostMapping("findNoticeByCond")
    @ApiOperation(value = "条件查询通知公告接口")
    public Result<Page<Notice>> findNoticeByCond(@RequestBody NoticeVo noticeVo) {
        return new Result<>(200, "请求成功", noticeService.findNoticeByCond(noticeVo));
    }

    @PostMapping("/addNotice")
    @ApiOperation(value = "添加通知公告")
    @OperLogAnnotation(business_type = "系统业务-增加通知公告", operator_type = 1)
    public Result<Integer> addNotice(Notice notice) {
        return new Result<>(200, "添加成功", noticeService.addNotice(notice));
    }

    @PostMapping("/getNoticeByNoticeId/{noticeId}")
    @ApiOperation(value = "根据公告Id查询到一个公告")
    public Result<Notice> getRoleByRoleId(@PathVariable Long noticeId) {
        return new Result<Notice>(200, "查询成功", noticeService.getNoticeById(noticeId));
    }

    @PostMapping("updateNotice")
    @ApiOperation(value = "修改公告信息")
    @OperLogAnnotation(business_type = "系统业务-修改通知公告", operator_type = 1)
    public Result updateNotice(@RequestBody Notice notice) {
        return new Result<>(200, "修改成功", noticeService.updateNotice(notice));
    }

    @DeleteMapping("deleteNoticeByNoticeIds/{ids}")
    @ApiOperation(value = "根据角色ID永久删除角色")
    @OperLogAnnotation(business_type = "系统业务-删除通知公告", operator_type = 1)
    public Result<Integer> deleteNoticeByNoticeIds(@PathVariable List<Long> ids) {
        return new Result<>(200, "删除成功", noticeService.deleteNoticeByIds(ids));
    }
}